<div class="user-content user-content-inter web-mgt20">
    <div class="main user-settings">
        <div class="setting-units">
            <div class="setting-unit">
                <div class="title">个人信息
                    <div class="preview">
                        <{$user_info['nickname']}>
                    </div>
                </div>
                <a class="edit-label icon-icon-19"></a>
                <div class="holder">
                    <form class="form-horizontal offset1" data-type="ajaxSubmit" action="<{:U('User/saveInfo')}>" method="post">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">昵称：</label>
                            <div class="col-sm-8">
                                <input id="txtName" type="text" name="nickname" class="form-control" maxlength="12" value="<{$user_info['nickname']}>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">姓名：</label>
                            <div class="col-sm-8">
                                <input id="txtName" type="text" name="name" class="form-control" maxlength="12" value="<{$user_info['name']}>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">性别：</label>
                            <div class="col-sm-8">
                                <{:form_select( 'sex',dict( 'gender'),$user_info[ 'sex'],array( 'class'=>'form-control'))}> </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">生日：</label>
                            <div class="col-sm-8 input-append ">
                                <input id="txtBirthday" name="birthday" data-date-format="yyyy-mm-dd" size="16" class="form-control datetimepicker" type="text" value="1993-01-01" readonly="true">
                                <span class="add-on"><i class="icon-th"></i></span> </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2"></div>
                            <div class="col-sm-8">
                                <input type="submit" class="btn-primary btn" value="更新资料" />
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="setting-unit">
                <div class="title">头像
                    <div class="preview avatar"> <img width="50" class="headimg" height="50" src="<{$user_info['headimg']}>"> </div>
                </div>
                <a class="edit-label  icon-icon-19"></a>
                <div class="holder">
                    <div class="offset2">
                        <div id="altContent">
                            <if condition="$is_mobile">
                                <form method="post" enctype="multipart/form-data" id="uploadHead" action="/BoxAddon/Upload/Index/upload/act/avatar" data-type="ajaxSubmit">
                                    <div style="position:relative; text-align:center; width:120px; margin:0 auto">
                                        <img width="100" style="border-radius:50%;" class="headimg" height="100" src="<{$user_info['headimg']}>">
                                        <div><a id="uploadText">上传头像</a></div>
                                        <input type="file" id="uploadBtn" name="file" style="width:100px; height:120px; top:0px; left:0px; position:absolute; filter:alpha(opacity=0); -moz-opacity:0; -khtml-opacity: 0; opacity: 0;" />
                                    </div>
                                </form>
                            </if>
                        </div>
                    </div>
                </div>
            </div>
            <div class="setting-unit">
                <div class="title">手机号
                    <div class="preview overflow-h">
                        <{$user_info[ 'mobile']?$user_info[ 'mobile']: '请设置您的手机号'}>
                    </div>
                </div>
                <a class="edit-label icon-icon-19"></a>
                <div class="holder">
                    <div class="offset1">
                        <{:Widget( 'BoxSns/User/setPhone')}>
                    </div>
                </div>
            </div>
            <div class="setting-unit" style="border-bottom:none">
                <div class="title">收货地址
                    <div class="preview overflow-h">
                        <{$user_info[ 'address']?$user_info[ 'address']: '请设置您的收货地址'}>
                    </div>
                </div>
                <a class="edit-label glyphicon icon-icon-19"></a>
                <div class="holder">
                    <div class="offset1">
                        <form class="form-horizontal" data-type="ajaxSubmit" action="<{:U('User/saveAddress')}>" method="post">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">地址：</label>
                                <div class="col-sm-8">
                                    <input type="text" name="address" value="<{$user_info['address']}>" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-2"></div>
                                <div class="col-sm-8">
                                    <button type="submit" class="btn-primary btn">确定</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
$("#uploadBtn").change(function() {
    $("#uploadText").text("上传中...");
    $("#uploadHead").submit();
})
$("#uploadHead").on("ajaxSubmitSuccess", function(e, content) {
    $("#uploadText").text("上传完成");
    var data = JSON.parse(content);
    if (data.error == 0) {
        $(".headimg").attr('src', data.data.file_url);
    } else {
        hiApp.alert(data.msg);
    }
})
</script>
<if condition="$is_mobile eq 0">
    <script type="text/javascript" src="__PUBLIC__/Js/plug/swfobject/swfobject.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Js/plug/swfobject/fullAvatarEditor.js"></script>
    <script type="text/javascript">
    swfobject.addDomLoadEvent(function() {
        var swf = new fullAvatarEditor("__PUBLIC__/Js/plug/swfobject/fullAvatarEditor.swf", "__PUBLIC__/Js/swfobject/expressInstall.swf", "altContent", {
            id: 'swf',
            upload_url: "/BoxAddon/Upload/Index/upload/act/avatar", //上传接口
            method: 'get', //传递到上传接口中的查询参数的提交方式。更改该值时，请注意更改上传接口中的查询参数的接收方式
            src_upload: 2, //是否上传原图片的选项，有以下值：0-不上传；1-上传；2-显示复选框由用户选择
            avatar_box_border_width: 0,
            avatar_sizes: '232*299',
            avatar_sizes_desc: '232*299',
            avatar_tools_visible: false,
            checkbox_visible: false
        }, function(msg) {
            console.log(msg);
            switch (msg.code) {
                case 1:
                    //alert("页面成功加载了组件！");
                    break;
                case 2:
                    //alert("已成功加载图片到编辑面板。");
                    document.getElementById("upload").style.display = "inline";
                    break;
                case 3:
                    if (msg.type == 0) {
                        alert("摄像头已准备就绪且用户已允许使用。");
                    } else if (msg.type == 1) {
                        alert("摄像头已准备就绪但用户未允许使用！");
                    } else {
                        alert("摄像头被占用！");
                    }
                    break;
            }
        });
    });
    </script>
</if>
